import { Exclude } from 'class-transformer'
import { Column, Entity } from 'typeorm'
import { SoftCompleteEntity } from '~/common/entity/common.entity'

export enum StudentStatus {
  DISABLED = 0,
  STUDYING = 1,
  PENDING_RENEWAL = 2,
  GRADUATED = 4,
}

export enum StudentType {
  ONLINE = 1,
  OFFLINE = 2,
}

@Entity({ name: 'c_student' })
export class StudentEntity extends SoftCompleteEntity {
  @Column({ name: 'student_id' })
  studentId: string

  @Column({ unique: true })
  phone: string

  @Column({ name: 'user_name' })
  userName: string

  @Exclude()
  @Column()
  password: string

  @Exclude()
  @Column()
  psalt: string

  @Column({ name: 'user_id' })
  userId: number

  @Column({ name: 'student_type', default: StudentType.ONLINE })
  studentType: StudentType

  @Column({ name: 'start_at', type: 'datetime' })
  startAt: Date

  @Column({ name: 'expire_at', type: 'datetime' })
  expireAt: Date

  @Column({ default: StudentStatus.STUDYING })
  status: StudentStatus
}
